let data = [
  [
    {
      src: 'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/35f352268526045e077a230802beb588.png?thumb=1&w=160&h=110&f=webp&q=90',
      text: 'Xiaomi MIX Fold 3',
      price: '8999元起',
    },
    {
      src: 'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/b4846501f1e9be04d6d2e859deb0d80e.png?thumb=1&w=160&h=110&f=webp&q=90',
      text: 'Xiaomi Civi 3',
      price: '2499元起',
    },
  ],
  [
    {
      src: 'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/7996692767ae8a8f3f83fb1c31fd6463.png?thumb=1&w=160&h=110&f=webp&q=90',
      text: 'Redmi Note 13 Pro',
      price: '1499元起',
    },
    {
      src: 'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/153321edb6fdddd89e77a560869ab521.png?thumb=1&w=160&h=110&f=webp&q=90',
      text: 'Redmi Note 13 Pro+',
      price: '1999元起',
    },
  ],
  [
    {
      src: 'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/86e6ab583d00578c60186cdefda67c16.png?thumb=1&w=160&h=110&f=webp&q=90',
      text: '小米电视 S Pro 65 Mini LED 65英寸',
      price: '4299元',
    },
    {
      src: 'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/d3fec390debf1164c8df721e821cc28a.png?thumb=1&w=160&h=110&f=webp&q=90',
      text: '小米电视新EA系列',
      price: '799元起',
    },
  ],
];

console.log(data);

let navList = document.querySelectorAll('.nav > li');
let navMain = document.querySelector('.main');
let box = document.querySelector('.box');

navList.forEach((el, index) => {
  el.addEventListener('mouseenter', () => {
    // console.log('index', index);
    // console.log(data[index]); // 获取当前分类数组集合
    data[index].forEach((data, dataIndex) => {
      // console.log(data, dataIndex);
      // 设置图片、价格、xxx
      navMain.children[dataIndex].children[0].src = data.src;
      navMain.children[dataIndex].children[1].innerText = data.text;
      navMain.children[dataIndex].children[2].innerText = data.price;
    });
    // 显示navMain的高度
    navMain.style.height = '200px';
  });
});

box.addEventListener('mouseleave', () => {
  navMain.style.height = '0';
});
